import React, {Component} from 'react';

import './index.less';

import {base, promptBox} from 'nc-lightapp-front';

const {
    NCModal,
    NCButton
} = base;

const {
    Header: NCHeader,
    Body: NCBody,
    Footer: NCFooter
} = NCModal;

class TreeNodeModal extends Component {
    constructor(props) {
        super(props);

        this.onClose = this.onClose.bind(this);
    }

    onClose() {
        const {
            onClose,
            form,
            language
        } = this.props;
        
        promptBox({
            color: 'warning',
            title: language['hi6007-000196'], // 确认取消
            content: language['hi6007-000009'], // 是否确认要取消,
            beSureBtnClick: () => {
                form.EmptyAllFormValue('folder');
                onClose && onClose();
            }
        });
    }

    render() {
        const {
            visible,
            form,
            language,
            submitTreeNode
        } = this.props;
        
        return (
            <NCModal
                show={visible}
                onHide={this.onClose}
            >
                <NCHeader
                    closeButton={true}
                >
                    {language['hi6007-000199']/** 报表目录 */}
                </NCHeader>
                <NCBody>
                    {form.createForm('folder')}
                </NCBody>
                <NCFooter>
                    <NCButton
                        colors="primary"
                        onClick={submitTreeNode}
                    >
                        {language['hi6007-000004']/** 确定 */}
                    </NCButton>
                    <NCButton
                        onClick={this.onClose}
                    >
                        {language['hi6007-000005']/** 取消 */}
                    </NCButton>
                </NCFooter>
            </NCModal>
        );
    }
}

export default TreeNodeModal;